import { Category } from 'src/modules/category/entities/category.entity';
// type TeamMatchType = 0 | 1; // '无' | '斯韦斯林杯赛制'
// type MatchType = '3局2胜' | '5局3胜' | '7局4胜' | '9局5胜' | '1局胜';
// type RallyType = '31' | '21';
// type TournamentType = '羽毛球' | '乒乓球' | '网球';
// type PlayerType = 1 | 2;
// type StageType = 1 | 2; // 淘汰赛, 循环赛
// type RoundNameType = 1 | 2 | 3; // 'ABCD' | '1234' | '一二三四' // 命名方式
// type RoundLoopType = 1 | 2; // '单循环' | '双循环' // 循环次数
// type RoundOrganizationType = 1 | 2 | 3; // '逆时针' | '顺时针' | '贝尔格' // 编排方式
export enum StageTypeEnum {
  Elimination = 1,
  Loop = 2,
}

export const stageTypeText = {
  [StageTypeEnum.Elimination]: '淘汰赛',
  [StageTypeEnum.Loop]: '循环赛',
}

export enum EventTypeEnum {
  nandan = 1,
  nvdan = 2,
  hundan = 3,
  nanshuang = 4,
  nvshuang = 5,
  hunshuang = 6,
  shuangda = 7,
  nantuan = 8,
  nvtuan = 9,
  huntuan = 10,
}

export enum CopyTypeEnum {
  Created = 10, // 赛事创建
  Signup = 20, // 报名
  Settle = 30, // 落位
  Schedule = 40, // 编排
  All = 50, // 全部
}
export const EventTypeText = {
  [EventTypeEnum.nandan]: '男单',
  [EventTypeEnum.nvdan]: '女单',
  [EventTypeEnum.hundan]: '混单', // 男vs女
  [EventTypeEnum.nanshuang]: '男双',
  [EventTypeEnum.nvshuang]: '女双',
  [EventTypeEnum.hunshuang]: '混双',
  [EventTypeEnum.shuangda]: '双打',
  [EventTypeEnum.nantuan]: '男团',
  [EventTypeEnum.nvtuan]: '女团',
  [EventTypeEnum.huntuan]: '混团',
};

export const EventText2Type = (() => {
  // 中文赛事名称和EventTypeEnum的映射
  const flippedObj = {};
  for (const key in EventTypeText) {
    if (EventTypeText.hasOwnProperty(key)) {
      flippedObj[EventTypeText[key]] = parseInt(key);
    }
  }
  return flippedObj;
})();

// 单打比赛
export const SingleEventList = [
  EventTypeEnum.nandan,
  EventTypeEnum.nvdan,
  EventTypeEnum.hundan,
];
// 双打比赛
export const DoubleEventList = [
  EventTypeEnum.nanshuang,
  EventTypeEnum.nvshuang,
  EventTypeEnum.hunshuang,
  EventTypeEnum.shuangda,
];
// 团队比赛
export const TeamEventList = [
  EventTypeEnum.nantuan,
  EventTypeEnum.nvtuan,
  EventTypeEnum.huntuan,
];
export const maleEventList = [
  EventTypeEnum.nandan,
  EventTypeEnum.nanshuang,
  EventTypeEnum.nantuan,
];
export const femaleEventList = [
  EventTypeEnum.nvdan,
  EventTypeEnum.nvshuang,
  EventTypeEnum.nvtuan,
];

export enum RoundOrganizationEnum {
  ClockWise = 1, //顺时针
  Anticlockwise = 2, //逆时针
  Berg = 3, // 贝尔格
}

export enum MatchStatusEnum { // 比赛状态
  Created = 1, // 已创建
  Ready = 2, // 签到中
  InProgress = 3, // 进行中
  Finished = 4, // 已结束
}

export enum MatchPlayerStatusEnum { // 比赛选手状态
  NotCheckIn = 1, // 未签到
  CheckedIn = 2, // 已签到
  GiveUp = 3, // 放弃
}

export enum GameStatusEnum { // 局比赛状态
  NotStarted = 1, // 未开始
  InProgress = 2, // 进行中
  Finished = 3, // 已结束
}

export enum StageStatusEnum { // 比赛阶段状态
  Created = 1, // 已创建
  InProgress = 10, // 进行中
  Finished = 30, // 已结束
}

export enum GroupStatusEnum {
  Created = 1, // 未开始
  InProgress = 10, // 进行中
  Finished = 30, // 已结束
}


export enum EventStatusEnum {
  Created = 1, // 未开始
  InProgress = 10, // 进行中
  Finished = 30, // 已结束
}

export enum CategoryStatusEnum {
  Created = 1, // 未开始
  InProgress = 10, // 进行中
  Finished = 30, // 已结束
}

export enum TournamentStatusEnum {
  Created = 1, // 未开始
  InProgress = 10, // 进行中
  Finished = 30, // 已结束
}

export const registrationIndexInitValue = 1;

export enum playerSignupTypeEnum { // 选手报名类型
  single = 1, // default 单人
  team = 2, // 团队
}

export enum StagePlayerSourceTypeEnum {
  winner = 1,
  loser = 2,
}

export enum RoleEnum {
  Admin = 'Admin', // 管理员
  Guest = 'Guest', // 游客
  Referee = 'Referee', // 裁判
  TournamentAdmin = 'TournamentAdmin', // 赛事管理员
}
